VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmEnhanceJOList 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Job Order List"
   ClientHeight    =   5340
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8565
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmEnhanceJOList.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5340
   ScaleWidth      =   8565
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame Frame4 
      Caption         =   "Product Listing"
      Height          =   2505
      Left            =   60
      TabIndex        =   8
      Top             =   2325
      Width           =   8430
      Begin MSComctlLib.ListView lvwList 
         Height          =   2130
         Left            =   120
         TabIndex        =   1
         Top             =   255
         Width           =   8190
         _ExtentX        =   14446
         _ExtentY        =   3757
         View            =   3
         Sorted          =   -1  'True
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         FullRowSelect   =   -1  'True
         GridLines       =   -1  'True
         HotTracking     =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   0
         NumItems        =   7
         BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Text            =   "Service"
            Object.Width           =   2646
         EndProperty
         BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   1
            Text            =   "Department ID"
            Object.Width           =   2646
         EndProperty
         BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   2
            Text            =   "Dept. Description"
            Object.Width           =   3528
         EndProperty
         BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   3
            Text            =   "Est. Date to Start"
            Object.Width           =   2646
         EndProperty
         BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   4
            Text            =   "Est. Date to Finish"
            Object.Width           =   2646
         EndProperty
         BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Alignment       =   1
            SubItemIndex    =   5
            Text            =   "Remarks"
            Object.Width           =   3528
         EndProperty
         BeginProperty ColumnHeader(7) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   6
            Text            =   "Reference Identity"
            Object.Width           =   0
         EndProperty
      End
   End
   Begin VB.Frame Frame1 
      Height          =   2205
      Left            =   60
      TabIndex        =   4
      Top             =   60
      Width           =   8430
      Begin MSComctlLib.ListView lvwRef 
         Height          =   1845
         Left            =   105
         TabIndex        =   0
         Top             =   225
         Width           =   1635
         _ExtentX        =   2884
         _ExtentY        =   3254
         View            =   3
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         FullRowSelect   =   -1  'True
         GridLines       =   -1  'True
         HotTracking     =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   0
         NumItems        =   1
         BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Text            =   "Reference No."
            Object.Width           =   2646
         EndProperty
      End
      Begin ITGControls.ITGTextBox txtRefRJONo 
         Height          =   285
         Left            =   2040
         TabIndex        =   5
         Top             =   240
         Width           =   2760
         _ExtentX        =   4657
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "JO Request No."
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1200
      End
      Begin ITGControls.ITGDateBox dtbDate 
         Height          =   285
         Left            =   3525
         TabIndex        =   6
         Tag             =   "Order Date"
         Top             =   600
         Width           =   1275
         _ExtentX        =   2249
         _ExtentY        =   503
         Enabled         =   0   'False
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   ""
         SendKeysTab     =   -1  'True
         Mandatory       =   -1  'True
         DatePicker      =   0   'False
      End
      Begin ITGControls.ITGLabel lblDate 
         Height          =   285
         Left            =   2085
         TabIndex        =   7
         Top             =   600
         Width           =   915
         _ExtentX        =   1614
         _ExtentY        =   503
         Caption         =   "Ref. Date"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
   End
   Begin ITGControls.ITGCommandButton cmdCancel 
      Height          =   345
      Left            =   7290
      TabIndex        =   3
      Top             =   4920
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   609
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&Cancel"
   End
   Begin ITGControls.ITGCommandButton cmdOK 
      Height          =   345
      Left            =   6030
      TabIndex        =   2
      Top             =   4920
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   609
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&OK"
   End
End
Attribute VB_Name = "frmEnhanceJOList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit

'Reference type
Enum eEnhanceListType
    JOForWO     'Job Order for Work Order
End Enum

Public mTranType As eEnhanceListType
Public mRefPK As String


Private connList As New ADODB.Connection

Private Sub cmdCAll_Click()
    If lvwList.ListItems.Count = 0 Then Exit Sub
    For i = 1 To lvwList.ListItems.Count
        lvwList.ListItems(i).Checked = True
    Next i
End Sub

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdOK_Click()
    Select Case mTranType
        Case JOForWO
            frmEnhanceWorkOrder.AddDetailsFromList
    End Select
    Unload Me
End Sub

Private Sub cmdUCAll_Click()
    If lvwList.ListItems.Count = 0 Then Exit Sub
    For i = 1 To lvwList.ListItems.Count
        lvwList.ListItems(i).Checked = False
    Next i
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyEscape Then
        Unload Me
    End If
End Sub

Private Sub Form_Load()
    
    Select Case mTranType
        Case JOForWO
            Reference "cTranNo", "V_JOForWO"
            Caption = "Job Order for Work Order List [Reference: Job Order]"
    End Select
    If lvwRef.ListItems.Count <> 0 Then lvwRef_ItemClick lvwRef.ListItems(lvwRef.SelectedItem.Index)
End Sub

'Reference list
Sub Reference(RefField As String, RefTable As String, Optional Condition As String)
    
    Set rs = New Recordset
    
    If Trim(Condition) <> "" Then
        Condition = " AND " & Condition
    End If
    
    'Select reference numbers
    sSQL = "SELECT DISTINCT " & Trim(RefField) & " AS cRefNo FROM " & Trim(RefTable) & " WHERE cCompanyID = '" & COID & "'" & Condition
    OpenNewConnection connList
    rs.Open sSQL, connList, adOpenForwardOnly, adLockReadOnly
    
    lvwRef.ListItems.Clear
    Do Until rs.EOF
        Set itmX = lvwRef.ListItems.Add(, , Trim(rs!cRefNo))
    rs.MoveNext
    Loop
    
    Set rs = Nothing

End Sub

'Sets the SQL Query for DR item details
Sub ListQuery(RefPK As String)
    Select Case mTranType
        Case JOForWO
            sSQL = "SELECT A.cRefRJONo AS RefName, " & _
                    "A.dDate AS RefDate FROM JO A " & _
                    "WHERE A.cTranNo = '" & Trim(RefPK) & "' AND A.cCompanyID = '" & COID & "'"
            ListHeader
            sSQL = "SELECT A.cService, A.DeptID, A.DeptDesc, A.dToStart, A.dEstToFinish, A.cRemarks, A.nIdentity " & _
                    "FROM JO_T A " & _
                    "WHERE A.cTranNo = '" & Trim(RefPK) & "' AND A.cCompanyID = '" & COID & "' AND A.cWONo IS NULL"
            ListDetail
        End Select

End Sub

'Header details
Sub ListHeader()
    Set rs = New Recordset
    OpenNewConnection connList
    rs.Open sSQL, connList, adOpenForwardOnly, adLockReadOnly
    If rs.RecordCount = 0 Then
        Set rs = Nothing
        Exit Sub
    End If
    txtRefRJONo = rs!refname & ""
    dtbDate.Text = Format(rs!RefDate, "MM/dd/yyyy")
    Set rs = Nothing
End Sub

Private Sub Form_Unload(Cancel As Integer)
    RepName = ""
    cString = ""
    Set connList = Nothing
    Set frmEnhanceJOList = Nothing
End Sub

Private Sub lvwList_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    lvwList.Sorted = True
    lvwList.SortKey = ColumnHeader.Index - 1
End Sub

Private Sub lvwList_KeyPress(KeyAscii As Integer)
    If lvwList.ListItems.Count = 0 Then Exit Sub
    If KeyAscii = 13 Then
        If lvwList.SelectedItem.Checked = True Then
            lvwList.SelectedItem.Checked = False
        Else
            lvwList.SelectedItem.Checked = True
        End If
    End If
End Sub

Private Sub lvwRef_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    lvwRef.Sorted = True
    lvwRef.SortKey = ColumnHeader.Index - 1
End Sub

Private Sub lvwRef_ItemClick(ByVal Item As MSComctlLib.ListItem)
    If lvwRef.ListItems.Count = 0 Then Exit Sub
    mRefPK = Trim(lvwRef.SelectedItem)
    ListQuery (Trim(lvwRef.SelectedItem))
End Sub

Private Sub lvwRef_KeyPress(KeyAscii As Integer)
    If lvwRef.ListItems.Count = 0 Then Exit Sub
    If KeyAscii = 13 Then lvwRef_ItemClick lvwRef.ListItems(lvwRef.SelectedItem.Index)
End Sub

'JO Details
Sub ListDetail()
    
    Set rs = New Recordset
    DoEvents
    
    OpenNewConnection connList
    rs.Open sSQL, connList, adOpenForwardOnly, adLockReadOnly
    lvwList.ListItems.Clear
    lvwList.Visible = False
    Do Until rs.EOF
        Set itmX = lvwList.ListItems.Add(, , Trim(rs!cService) & "")
        itmX.SubItems(1) = Trim(rs!DeptID) & ""
        itmX.SubItems(2) = Trim(rs!DeptDesc) & ""
        itmX.SubItems(3) = Format(rs!dToStart, "mm/dd/yyyy") & ""
        itmX.SubItems(4) = Format(rs!dEstToFinish, "mm/dd/yyyy") & ""
        itmX.SubItems(5) = Trim(rs!cRemarks) & ""
        itmX.SubItems(6) = rs!nIdentity & ""
        rs.MoveNext
    Loop
    
    lvwList.Visible = True
    Set rs = Nothing
End Sub


